// Guess the Letter game, 4th version
class Guess4 {
    public static void main(String args[])
        throws java.io.IOException {

        char ch, ignore, answer = 'K';

        do {
            System.out.println("I'm thinking of a letter b/w A and Z.");
            System.out.print("Can you guess it? ");

            // read a character
            
            ch = (char) System.in.read();

            // discard any other characters in the input buffer
            do {
                ignore = (char) System.in.read();
            } while(ignore != '\n');

            if(ch == answer) System.out.println("*** Right ***");
            else {
                System.out.print("...Sorry, your answer is ");
                if(ch > answer) System.out.println("too high!");
                else System.out.println("too low!");
                System.out.println("Please try again.\n");
            }
        } while(ch != answer);
    }
}

